package uk.org.landeg.euler.problems;

import java.util.Arrays;

import uk.org.landeg.euler.problems.framework.AbstractProblem;
import uk.org.landeg.euler.problems.framework.ProblemLauncher;
import uk.org.landeg.euler.problems.lib.NumbersLib;

public class Problem052 extends AbstractProblem{
	public static void main(String[] args) {
		ProblemLauncher launcher = new ProblemLauncher(new Problem052());
		launcher.solve();		
	}

	@Override
	public String getDescription() {
		return "Find the smallest positive integer, x, such that 2x, 3x, 4x, 5x, and 6x, contain the same digits";
	}

	@Override
	public Integer getProblemNumber() {
		return 52;
	}

	@Override
	public Object solve() {
		int [] sum = new int [10];
		int [] isum = new int[10];
		int [] prod;
		int digits[];
		boolean finished = false;
		int n = 1;
		int mults[] = new int[7];
		do {
			digits = NumbersLib.digitCount(n);
			finished = true;
			for (int x = 2 ; x < mults.length ; x++) {
				mults[x] = x*n;
				if (!(Arrays.equals(NumbersLib.digitCount(mults[x]),digits))) {
					finished = false;
					break;
				} else {
					System.out.println(n + "  *" + x + "  " + mults[x]);
				}
			}
			n++;
		} while (!finished);
		return n;
	}

}
